﻿/*====================================================================================
	TASK 10:                                              { Operators and Expressions}
	Write a boolean expression that returns if the bit at position p (counting from 0)
    in a given integer number v has value of 1.
    Example: v=5; p=1 => false.        
====================================================================================*/

using System;


class HasOrHasNotValueOne
{
    static void Main()
    {
        Console.Write("Enter integer number:");
        int v = int.Parse(Console.ReadLine());

        Console.WriteLine("number in binary is:{0}", Convert.ToString(v, 2));
        
        Console.Write("Enter position which you want to check:");
        int p = int.Parse(Console.ReadLine());
        
        int mask = 1 << p;
        int numberAndMask = v & mask;
        int position1Bit = numberAndMask >> p;
        
        bool check=(position1Bit==1);
        Console.WriteLine("Is there has 1 of position 1?\nAnswer is:{0}",check);
    }
}

